package com.sqx.modules.scFollow.controller.app;

import com.sqx.common.utils.Result;
import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.goods.service.GoodsService;
import com.sqx.modules.scFollow.entity.ScFollow;
import com.sqx.modules.scFollow.service.ScFollowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/scFollow/")
@Api(value = "收藏|关注-用户端", tags = {"收藏|关注-用户端"})
public class AppScFollowController {
    @Autowired
    private ScFollowService scFollowService;
    @Autowired
    private GoodsService goodsService;


    @Login
    @ApiOperation("收藏-取消收藏|想要-取消想要")
    @PostMapping("updateFollow")
    public Result updateFollow(@ApiParam("用户id") @RequestAttribute("userId") Long userId,
                               @ApiParam("商品收藏、商品想要、关注用户、收藏动态实体") ScFollow follow) {
        follow.setUserId(userId);
        return scFollowService.updateFollow(follow);
    }

    @Login
    @ApiOperation("获取我的收藏|想要列表")
    @PostMapping("getFollowGoodsList")
    public Result getFollowGoodsList(@ApiParam("用户id") @RequestAttribute Long userId,
                                     @ApiParam("页码") Integer page,
                                     @ApiParam("条数") Integer limit,
                                     @ApiParam("商品收藏、商品想要、关注用户、收藏动态实体") ScFollow follow) {
        return Result.success().put("data", scFollowService.getFollowGoodsList(userId, page, limit, follow));
    }

    @Login
    @ApiOperation("获取我收藏的动态列表")
    @PostMapping("selectByMyCollect")
    public Result selectByMyCollect(@ApiParam("用户id") @RequestAttribute Long userId,
                                    @ApiParam("页码") Integer page,
                                    @ApiParam("条数") Integer limit,
                                    @ApiParam("商品收藏、商品想要、关注用户、收藏动态实体") ScFollow follow) {
        return Result.success().put("data", scFollowService.selectByMyCollect(userId, page, limit, follow));
    }

    @Login
    @ApiOperation("app用户端查看我的足迹列表")
    @GetMapping("selectMyFootprintList")
    public Result selectMyFootprintList(@ApiParam("用户id") @RequestAttribute Long userId,
                                        @ApiParam("页码") Integer pageNum,
                                        @ApiParam("条数") Integer pageSize,
                                        @ApiParam("状态") Integer status) {
        return scFollowService.selectMyFootprintList(userId, pageNum, pageSize,status);
    }

    @Login
    @ApiOperation("查看我关注的用户列表")
    @GetMapping("getFollowList")
    public Result getFollowList(@ApiParam("用户id") @RequestAttribute Long userId,
                                @ApiParam("页码") Integer pageNum,
                                @ApiParam("条数") Integer pageSize) {
        return scFollowService.getFollowList(userId, pageNum, pageSize);
    }

    @Login
    @ApiOperation("查看我的粉丝列表,isMutualFollow为0是单向关注(即回关)，1是互相关注")
    @GetMapping("getFanList")
    public Result getFanList(@ApiParam("用户id") @RequestAttribute Long userId,
                             @ApiParam("页码") Integer pageNum,
                             @ApiParam("条数") Integer pageSize) {
        return scFollowService.getFanList(userId, pageNum, pageSize);
    }
}
